﻿<?php

use yii\helpers\Html;
use yii\helpers\Url;
use backend\widgets\GridView;
?>
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <?php echo Html::csrfMetaTags(); ?>
    <link href="<?php echo Yii::$app->homeUrl; ?>css/common/base.css" rel="stylesheet">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/common/common.css" rel="stylesheet">
    <link rel="stylesheet" href="<?php echo Yii::$app->homeUrl; ?>css/common/bootstrap.min.css">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/common/daterangepicker-bs3.css" rel="stylesheet">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/PassList.css" rel="stylesheet">
    <link href="<?php echo Yii::$app->homeUrl; ?>css/ThePass.css" rel="stylesheet">
    <!-- The script --> 
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/jquery-2.1.1.min.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/bootstrap.min.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/extendPagination.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/moment.js"></script>
    <script type="text/javascript" src="<?php echo Yii::$app->homeUrl; ?>js/daterangepicker.js"></script>
    <?php $this->head() ?>
</head>
<?php $this->beginBody() ?>
    <div class="newPass">
            <h4>
                频道与分类修改
                <span class="fenle_span">
                    (单选)
                </span>
                <k class="fenle_k">
                    已选<?php echo $nums;?>本
                </k>
            </h4>
            <div class="TopUl_Atable">
                <div class="TopUl_Atable_nv">
                    <table class="Atable mytable TopUl_Atable_nvone">
                        <tr>
                            <td colspan="2">
                                女频
                            </td>
                        </tr>
                        <?php foreach($nv_datas as $v):?>
                            <tr class="TR">
                                <td>
                                    <input name="r" class="styled Checkbox Checkboxnv checkbox1" type="radio"  value="<?php echo $v['cate_id']; ?>" />
                                </td>
                                <td>
                                    <?php echo $v['cate_name'];?>
                                </td>
                            </tr>
                        <?php endforeach;?>
                    </table>
                </div>
                <div class="TopUl_Atable_nan">
                    <table class="Atable mytable TopUl_Atable_nvone nan">
                        <tr>
                             <td colspan="2" >
                                男频
                            </td>
                        </tr>
                        <?php foreach($nan_datas as $v):?>
                            <tr class="TR">
                                <td>
                                    <input name="r" class="styled Checkbox Checkboxnv checkbox1" type="radio"  value="<?php echo $v['cate_id']; ?>" />
                                </td>
                                <td>
                                    <?php echo $v['cate_name'];?>
                                </td>
                            </tr>
                        <?php endforeach;?>
                    </table>
                </div>
            </div>
         <p class="lassLI">
            <?= Html::submitButton('保存创建', ['class' => 'single btn btn-primary tw_QDOK', 'name' => 'submit-button']) ?>
            <?= Html::submitButton('返回', ['class' => 'back btn btn-primary tw_QDOK', 'name' => 'submit-button']) ?>
        </p>
            
        </div>
        <div class="bottom">
        </div>
<?php $this->endBody() ?>
<script>
$(function(){
    $(".back").click(function(){
       window.location.href = "/novel/index" 
    });
    $(".sub").click(function(){
            var cid = $('input:radio:checked').val();
            if(zz_keys == ''){
                alert('请选择需要操作的小说');
                return false;
            }
            var id = zz_keys;
            $.ajax({
                url: "/novel/post-up-cate-batch",
                type: "POST",
                dataType: "json",
                data: {'cid':cid,'id':id},
                success: function(Data) {
                    if(Data.status == 0){
                        alert('保存成功');
                    }else{
                        alert('保存失败');
                    }
                    location.href="/novel/index"
                    zz_keys = ''
                },
                error: function() {
                    alert('网络错误！');
                    location.href="/novel/index"
                    zz_keys = ''
                }
            });
         });
    
    $(".single").click(function(){
        var cid = $('input:radio:checked').val();
        var id = request('id');
         if(cid == undefined ){
            alert('请选择分类');
            return false;
        }
        $.ajax({
            url: "/novel/post-up-cate-batch",
            type: "POST",
            dataType: "json",
            data: {'cid':cid,'id':id.split(',')},
            success: function(Data) {
                if(Data.status == 0){
                    alert('保存成功');
                }else{
                    alert('保存失败');
                }
                location.href="/novel/index"
            },
            error: function() {
                alert('网络错误！');
                location.href="/novel/index"
            }
        });
     });
     function request(paras){   
        var url = location.href;   
        var paraString = url.substring(url.indexOf("?")+1,url.length).split("&");   
        var paraObj = {}   
        for (i=0; j=paraString[i]; i++){   
            paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length);   
        }   
        var returnValue = paraObj[paras.toLowerCase()];   
        if(typeof(returnValue)=="undefined"){   
            return "";   
        }else{   
            return returnValue;   
        }   
    } 
})    
</script>